<template>
	<view class="f-page">
    <u-row>
      <u-col span="4"/>
      <u-col span="4"><u--image :src="theme.icon" width="90px" height="120px"/></u-col>
      <u-col span="4"/>
    </u-row>
    <u--text type="info" :text="theme.name" size='20'></u--text>
    <u-gap height="10"></u-gap>
    <u--text type="info" :text="'简介'" size='20'></u--text>
    <u-gap height="10"></u-gap>
    <u--text type="info" :text="theme.desc"></u--text>
    <u-gap height="10"></u-gap>
    <u-gap height="5"></u-gap>
    <u--text type="info" :text="'作品（收录963首）'" size='16'></u--text>
    <u-gap height="10"></u-gap>
    <u-loading-icon :show="loading"/>
    <u-list @scrolltolower="scrolltolower">
			<u-list-item v-for="(item, index) in poetList" :key="index">
        <u-cell :label="item.shortContent" :title="item.title" :value="item.origin" :titleStyle="style.titleStyle"
          @click="navTo('/pagework/poetry/detail?id=',item.id)"></u-cell>
		  </u-list-item>
		</u-list>
    <u-divider text="没有更多了" v-if="finished"></u-divider>
	</view>
</template>
<script>


import { theme,fetchPoemList,fetchQuoteList} from '@/api/poetry'
export default {
	data() {
		return {
      style: {
        fontSize: 16,
        titleStyle: {'font-size': '15px','color': '#3c9cff'}
      },
      option: {},
      loading: false,
      finished: false,
      totalPage: 0,
      listQuery: {page: 1},
      theme: {},
      poetList: []
		}
	},
  onLoad: function(option) {
    this.option = option
    this.getAuthor()
    this.loadmore()
  },
	methods: {
    scrolltolower() {
      if (this.listQuery.page < this.totalPage) {
        this.listQuery.page = this.listQuery.page + 1
        this.loadmore()
      }else{
        this.finished = true
      }

    },
    getAuthor(){
      let kindId = this.option.kindId
      let cat = this.option.cat
      theme({params:  {kindId: kindId,cat: cat},custom: { auth: true,toast: false }}).then(response => {
        this.theme = response.data
      })
    },
    loadmore() {
      this.loading = true
      this.listQuery.kindId = this.option.kindId
      this.listQuery.cat = this.option.cat
      this.listQuery.name = this.option.name
      if(this.option.kindId === 0){
        fetchPoemList( {params: this.listQuery,custom: { auth: true,toast: false }}).then(response => {
          this.poetList = this.poetList.concat(response.data.records)
          this.totalPage = response.data.pages
          this.loading = false;
        })
      }else{
        fetchQuoteList( {params: this.listQuery,custom: { auth: true,toast: false }}).then(response => {
          this.poetList = this.poetList.concat(response.data.records)
          this.totalPage = response.data.pages
          this.loading = false;
        })
      }
    },
    navTo(url,id) {
      uni.$u.route(url, {id: id});
    }

	}

}
</script>
<style lang="scss">



</style>
